#!/bin/bash

#Desc:install mongodb by binary file
#Author:zhang huan
#Create:2020-09-17
#Update:
#Usage:

#package path
sourcePath=$1
#unpack path
unpackPath=mongodb

#unpack and mv files
mkdir $unpackPath
tar -zxf  $sourcePath  -C $unpackPath
mv $unpackPath/* /usr/local/mongodb

cd /usr/local/mongodb
mkdir data logs


#create start script
cat > mongodbd.sh <<EOF
#!/bin/bash
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data  --logpath=/usr/local/mongodb/logs/mongodb.log --fork
EOF
chmod +x mongodbd.sh

#start
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data  --logpath=/usr/local/mongodb/logs/mongodb.log --fork
